package com.study.mirrorforest.main.model.auth.controller;

import com.study.mirrorforest.main.common.response.R;
import com.study.mirrorforest.main.model.auth.dto.LoginDTO;
import com.study.mirrorforest.main.model.auth.dto.RegisterDTO;
import com.study.mirrorforest.main.model.auth.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/api/auth")
public class AuthController {

    @Autowired
    private AuthService authService;


    @PostMapping(value = "/login")
    public R login(@RequestBody LoginDTO loginDTO) {
        System.out.println("[AuthController] login called with: " + loginDTO);
        return authService.login(loginDTO);
    }


    @PostMapping(value = "/register")
    public R register(@RequestBody RegisterDTO registerDTO) {
        System.out.println("[AuthController] register called with: " + registerDTO);
        return authService.register(registerDTO);
    }
}
